<%

Function rodada_deletar_jogo(id_rodada, posicao)

		
		str = "SELECT total_jogos from rodadas where simulacao=0 and completa=0 and id="&id_rodada
  		Set rs = conexao_geral.Execute(str)	
		
		str = "SELECT posicao from rodadas_jogos where id_rodada="&id_rodada&" AND posicao="&posicao
  		Set rs2 = conexao_geral.Execute(str)	
		
		If not rs.eof and not rs2.eof then
		
			DIM nova_posicao, total_jogos
		
			total_jogos = rs("total_jogos")-1
			
			str = "UPDATE rodadas SET "
			str = str & "total_jogos='"&total_jogos&"' "
			str = str & " WHERE id="&id_rodada
			Set rsI = conexao_geral.Execute(str)
			
			str = "DELETE from rodadas_jogos where id_rodada="&id_rodada&" and posicao="&posicao
  			Set rs = conexao_geral.Execute(str)	
			
			str = "DELETE from apostas where id_rodada="&id_rodada&" and posicao="&posicao
  			Set rs = conexao_geral.Execute(str)	
			
			str = "SELECT posicao from rodadas_jogos where id_rodada="&id_rodada&" and posicao>"&posicao&" order by posicao asc"
  			Set rs2 = conexao_geral.Execute(str)	
			
			DO while not rs2.eof 
			
				nova_posicao = rs2("posicao")-1
				
				rodada_alterar_jogo_posicao id_rodada, nova_posicao, (nova_posicao+1)
				
			
			rs2.MoveNext
			Loop
			
	 End If

End Function
%>
